﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace LazyMapper.Tests.LazyMapper.Core
{
    internal static class AssertHelper
    {
        public static Exception Throws(Action call)
        {
            return Throws<Exception>(call);
        }

        public static T Throws<T>(Action call) where T : Exception
        {
            try
            {
                call();
            }
            catch (T e)
            {
                return e;
            }
            Assert.Fail(string.Format("{0} Expected ", typeof(T).Name));
            return null;
        }
    }
}